<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>



</body>
<script>

    //     移动端
    // iPhone,iPad,Android,BB10,PlayBook,Windows Phone,MeeGo

    console.log(navigator.userAgent);

    var appList = ["iPhone", "iPad", "Android", "BB10", "PlayBook", "Windows Phone", "MeeGo"];

    var flag = false;  //假设是PC端
    var appType = "Windows";
    for (var i = 0; i < appList.length; i++) {
        var app = appList[i];
        var userAgent = navigator.userAgent;
        if (userAgent.indexOf(app) != -1) {
            flag = true;
            appType = app;
            break;
        }
    }
    if (flag) {
        document.write("移动端;你的手机是" + appType);
    } else {
        document.write("PC端;你的手机是" + appType);
    }


    console.log(isApp());
    // document.write("移动端;你的手机是" + app);
    // break;

    // function isApp() {
    //     var appList = ["iPhone", "iPad", "Android", "BB10", "PlayBook", "Windows Phone", "MeeGo"];
    //     var msg = {
    //         status: false,
    //         appType: "Windows"
    //     }

    //     var flag = false;  //假设是PC端
    //     var appType = "Windows";
    //     for (var i = 0; i < appList.length; i++) {
    //         var app = appList[i];
    //         var userAgent = navigator.userAgent;
    //         if (userAgent.indexOf(app) != -1) {
    //             flag = true;
    //             appType = app;
    //             break;
    //         }
    //     }
    //     if (flag) {
    //         msg.status = true;
    //         msg["appType"] = appType;
    //     }
    //     return msg;
    // }


    function isApp() {
        var appList = ["iPhone", "iPad", "Android", "BB10", "PlayBook", "Windows Phone", "MeeGo"];

        var flag = false;  //假设是PC端
        var appType = "Windows";
        for (var i = 0; i < appList.length; i++) {
            var app = appList[i];
            var userAgent = navigator.userAgent;
            if (userAgent.indexOf(app) != -1) {
                flag = true;
                appType = app;
                break;
            }
        }
        if (flag) {
            var msg = {
                status: true,
                appType: appType
            }
        } else {
            var msg = {
                status: false,
                appType: "window"
            }
        }
        return msg;
    }





</script>

</html>